home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / nShell™ drop / How To next >
Encoding:
Text File  |  1994-09-18  |  3.8 KB  |  116 lines  |  [TEXT/ttxt]

  1. How To
  2. ======
  3.  
  4. The nShell drag and drop template may be used from any folder.
  5.  
  6. This package also contains a new "read" command and a replacement "man" command.  Please drop these files in your nShell "bin" directory.
  7.  
  8. This is an experimental release.  If you encounter any problems, please write to:
  9.  
  10. John Jensen <jjensen@kaiwan.com>
  11.  
  12. Thank you.
  13.  
  14. Known Problems
  15. --------------
  16.  
  17. On my system, scripts fail to run when I drop a large number of files on them (>100).
  18.  
  19. Background
  20. ----------
  21.  
  22. The "nShell™ drop" template allows nShell scripts to be converted into drag and drop applications.  This template requires that a copy of the nShell™ or nShell-Pro™ application be installed on your system.  Version 1.0.2 of the nShell may be found on the info-mac archive at:
  23.  
  24. /info-mac/dev/n-shell-102.hqx
  25.  
  26. That package also contains a hypertext User's Guide which describes nShell scripting.
  27.  
  28. Writing a script
  29. ----------------
  30.  
  31. Make a copy of "nShell™ drop".  You can use the finder "Duplicate" function, or the nShell "cp" command.  Give this copy of the drag and drop template a unique name.
  32.  
  33. Method 1 - Direct Editing
  34. -------------------------
  35.  
  36. Drag your new icon onto a BBEdit icon, and type in your script.  Close the file and you're done.
  37.  
  38. Method 2 - Appending a file
  39. ---------------------------
  40.  
  41. If you have an existing script file which you would like to make into a drag and drop application, you can 'cat' the file onto a copy of the "nShell™ drop" template:
  42.  
  43. cat my_script >> template_copy
  44.  
  45. and you're done.
  46.  
  47. NOTE:  Never use the ">" operator, as this will delete and replace the target with a new TEXT file.
  48.  
  49. Parameters
  50. ----------
  51.  
  52. The normal script parameters $#, $0...$n will be set up with any items dropped onto the application.  Specifically:
  53.  
  54. $# = The number of parameters (1 = script only, 2 = script + 1 param, etc.)
  55. $0 = The name of the script (not a full pathname)
  56. $1 = The full pathname of the first dropped item
  57. $2 = The full pathname of the second dropped item
  58. ...
  59.  
  60. The parameters may be files, folders, or disks but are always represented as pathnames.  Remember to use quotes around these variables, as in
  61.  
  62. chattr "$1" -c 'R*ch'
  63.  
  64. Limitations:  The total length of all dropped pathnames may not exceed 4096 characters.  Beyond this input is ignored.  Only those files dropped on the application as it is opened are set as parameters.  Anything dropped on the script after it is running is ignored (the finder is given an errAEEventNotHandled).
  65.  
  66. System Variables
  67. ----------------
  68.  
  69. On startup, drag and drop applications search out the nShell application and set their paths based upon that directory.  The defaults are:
  70.  
  71. PWD = "drag and drop application directory"
  72. HOME = "nShell application directory"
  73. PATH = ":/nShell application directory:bin"
  74. TMP = "nShell application directory:tmp"
  75.  
  76. Memory
  77. ------
  78.  
  79. I've set the default to memory size to 200k.  When I dropped 88 files on a script it used up a lot of that.  If you think you are going to need it, bump the memory.  nShell and the template start complaining about low memory when 80k is left.
  80.  
  81. Hint #1
  82. -------
  83.  
  84. If you're not sure what's going on with a drag an drop script, add
  85.  
  86. env
  87. echo ' '
  88. echo 'Press <Return> to continue...'
  89. echo ' '
  90. read foo
  91.  
  92. as the first line.  That'll tell you what your dropped files ended up looking like. 
  93.  
  94. And if you don't want to fall off the end of the script right away, use 'delay 5' or 'read foo' or something as the last line.
  95.  
  96. Hint #2
  97. -------
  98.  
  99. Any script can run any other script.  So create a drag and drop application containing the line
  100.  
  101. "$1"
  102.  
  103. and you have a program that will run any nShell script dropped on it.
  104.  
  105. System 6
  106. --------
  107.  
  108. Under System 6, "nShell™ drop" applications serve as "clickable scripts".  There is no way to provide start-up parameters.  In addition, the applications must reside in the nShell application directory when running under System 6.
  109.  
  110. Thanks
  111. ------
  112.  
  113. Thanks for your help,
  114.  
  115. John
  116.